#pragma once

#include <cstdint>
#include <algorithm>

class pos {
public:
    pos() = default;
    pos(int row, int col) : row_(row), col_(col) { }

    /* TODO: initialize_list */

    int row() const { return row_; }
    void set_row(int row) { row_ = row; }

    int col() const { return col_; }
    void set_col(int col) { col_ = col; }

    bool operator==(const pos& pos) const
    {
        return row_ == pos.row_ && col_ == pos.col_;
    }

    static bool is_same(const pos& pos1, const pos& pos2)
    {
        return (pos1.row() == pos2.row()) && (pos1.col() == pos2.col());
    }

    static bool is_adjacent(const pos& pos1, const pos& pos2)
    {
        /* 相同的位置不为相邻 */
        if ((pos1.row() == pos2.row()) && (pos1.col() == pos2.col())) {
            return false;
        }

        if ((std::abs(pos1.row() - pos2.row()) <= 1) && 
            (std::abs(pos1.col() - pos2.col()) <= 1)) {
            return true;
        }

        return false;
    }

private:
    int row_ = 0;
    int col_ = 0;
};
